package org.ITschool.dwr.utilcontroller;

import javax.servlet.http.HttpSession;

import net.sf.json.JSON;
import net.sf.json.JSONObject;

import org.ITschool.support.util.UploadProcessLister;
import org.ITschool.support.util.processbanner;
import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;

public class Uploadprocess {
   public JSON uploadprocessload(){
	    WebContext webContext=WebContextFactory.get();
	    HttpSession session=webContext.getSession();
	    processbanner processbanner=new processbanner();
	    processbanner uLister=(processbanner)session.getAttribute("uplistener");
          if(uLister==null){
        	  uLister=processbanner;
          }
	    double b=uLister.getPercent();
         int a=0;
         if(b>0.009){
        	 a=(int)Math.rint(b*100);
         }
	    JSONObject json=new JSONObject();
        json.put("data3", uLister.getAllSize());
        json.put("data2", uLister.getUseTime());
        json.put("data1", a+"%");
        json.put("bannervalue", a);
	    return json;
   }
}
